package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.LuntaiVideoLog;
import com.ruoyi.system.domain.dto.TyreInstallLogDto;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiTyreInstallLog;
import com.ruoyi.system.service.ILuntaiTyreInstallLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮胎安装记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/tyreInstallLog")
public class LuntaiTyreInstallLogController extends BaseController
{
    @Autowired
    private ILuntaiTyreInstallLogService luntaiTyreInstallLogService;

    /**
     * 查询轮胎安装记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LuntaiTyreInstallLog luntaiTyreInstallLog)
    {
        startPage();
        List<LuntaiTyreInstallLog> list = luntaiTyreInstallLogService.selectLuntaiTyreInstallLogList(luntaiTyreInstallLog);
        return getDataTable(list);
    }
    @GetMapping("/list2")
    public AjaxResult list2(LuntaiTyreInstallLog luntaiTyreInstallLog)
    {
        List<LuntaiTyreInstallLog> list = luntaiTyreInstallLogService.selectLuntaiTyreInstallLogList(luntaiTyreInstallLog);
        return AjaxResult.success(list);
    }

    /**
     * 导出轮胎安装记录列表
     */
    @Log(title = "轮胎安装记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiTyreInstallLog luntaiTyreInstallLog)
    {
        List<LuntaiTyreInstallLog> list = luntaiTyreInstallLogService.selectLuntaiTyreInstallLogList(luntaiTyreInstallLog);
        ExcelUtil<LuntaiTyreInstallLog> util = new ExcelUtil<LuntaiTyreInstallLog>(LuntaiTyreInstallLog.class);
        util.exportExcel(response, list, "轮胎安装记录数据");
    }

    /**
     * 获取轮胎安装记录详细信息
     */
    @ApiOperation(value = "（新）根据车辆id查询车轮胎")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "carId", value = "车辆id")
    })
    @PostMapping("/getTyreListByCarId2")
    public AjaxResult getTyreListByCarId2(@RequestParam Integer carId) {
        List<TyreInstallLogDto> tyreList = luntaiTyreInstallLogService.getTyreListByCarId2(carId);
        return AjaxResult.success("查询成功",tyreList);
    }

    /**
     * 获取轮胎安装记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiTyreInstallLogService.selectLuntaiTyreInstallLogById(id));
    }

    /**
     * 新增轮胎安装记录
     */
    @Log(title = "轮胎安装记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiTyreInstallLog luntaiTyreInstallLog)
    {
        return toAjax(luntaiTyreInstallLogService.insertLuntaiTyreInstallLog(luntaiTyreInstallLog));
    }

    /**
     * 修改轮胎安装记录
     */
    @Log(title = "轮胎安装记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiTyreInstallLog luntaiTyreInstallLog)
    {
        return toAjax(luntaiTyreInstallLogService.updateLuntaiTyreInstallLog(luntaiTyreInstallLog));
    }

    /**
     * 删除轮胎安装记录
     */
    @Log(title = "轮胎安装记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiTyreInstallLogService.deleteLuntaiTyreInstallLogByIds(ids));
    }
    /**
     * 查询轮胎安装记录列表
     */
    @PostMapping("/getVideoList")
    public TableDataInfo getVideoList(@RequestBody LuntaiVideoLog videoLog)
    {
        startPage();
        List<LuntaiVideoLog> list = luntaiTyreInstallLogService.getVideoList(videoLog);
        return getDataTable(list);
    }
    /**
     * 查询轮胎安装记录列表
     */
    @PostMapping("/deleteVideo")
    public AjaxResult deleteVideo(@RequestParam Integer id)
    {
        return toAjax(luntaiTyreInstallLogService.deleteVideo(id));
    }
    /**
     * 删除安装记录
     */
    @PostMapping("/deleteTyreLog")
    public AjaxResult deleteTyreLog(@RequestParam Integer id)
    {
        return toAjax(luntaiTyreInstallLogService.deleteTyreLog(id));
    }

    /**
     * 删除安装记录
     */
    @PostMapping("/installLogByLicensePlate")
    public AjaxResult installLogByLicensePlate(@RequestParam String licensePlate)
    {
        List<TyreInstallLogDto> installLogList = luntaiTyreInstallLogService.installLogByLicensePlate(licensePlate);
        return success(installLogList);
    }

}
